package cn.iocoder.yudao.module.resource.dal.mysql.usertimetransaction;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.module.resource.controller.admin.usertimetransaction.vo.UserTimeTransactionPageReqVO;
import cn.iocoder.yudao.module.resource.dal.dataobject.usertimetransaction.UserTimeTransactionDO;
import org.apache.ibatis.annotations.Mapper;

/**
 * 用户时长交易记录 Mapper
 *
 * @author lizhongwen
 */
@Mapper
public interface UserTimeTransactionMapper extends BaseMapperX<UserTimeTransactionDO> {

    default PageResult<UserTimeTransactionDO> selectPage(UserTimeTransactionPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<UserTimeTransactionDO>()
                .eqIfPresent(UserTimeTransactionDO::getId, reqVO.getId())
                .eqIfPresent(UserTimeTransactionDO::getUserId, reqVO.getUserId())
                .eqIfPresent(UserTimeTransactionDO::getTransactionType, reqVO.getTransactionType())
                .betweenIfPresent(UserTimeTransactionDO::getTransactionTimeMs, reqVO.getTransactionTimeMs())
                .betweenIfPresent(UserTimeTransactionDO::getRemainingTimeMs, reqVO.getRemainingTimeMs())
                .eqIfPresent(UserTimeTransactionDO::getOrderId, reqVO.getOrderId())
                .betweenIfPresent(UserTimeTransactionDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(UserTimeTransactionDO::getId));
    }

}